<?php
//展示调货申请记录模块，Input = NULL，Output = 本店的调货申请记录
header("content-type:application/json;charset=utf-8");

include_once "0.1conn.php"; //连接数据库

session_start();
$shop_id = $_SESSION['user']['shop_id'];
$query = "SELECT * FROM transfer_record WHERE ask_shop = '$shop_id'";

$arr62 = array();
if ($result = mysqli_query($conn, $query)) {
    //显示查询结果
    while ($row = mysqli_fetch_assoc($result)) {
        //查找每一条的相关联的商品信息
        $gid = $row['good_id'];
        $sid = $row['ans_shop'];
        $query2 = "SELECT * FROM clothes WHERE good_id = '$gid' AND shop_id = '$sid'";
        $good_detail = mysqli_fetch_assoc(mysqli_query($conn, $query2));
        $good_detail['id'] = $row['id'];
        $good_detail['num'] = $row['num'];
        $good_detail['ans_shop'] = $row['ans_shop'];
        if($row['status'] == "yes"){
            $good_detail['status'] = "被接受";
        }else if($row['status'] == "no"){
            $good_detail['status'] = "被拒绝";
        }else{
            $good_detail['status'] = "等待对方审批";
        }
        $arr62[] = $good_detail;
    }
    //释放结果集合
    mysqli_free_result($result);
}
echo json_encode($arr62);
//关闭连接
mysqli_close($conn);

